import launch, launch_ros

def generate_launch_description():
    # 1.声明一个launch参数
    action_declare_arg_background_g = launch.actions.DeclareLaunchArgument('launch_arg_bg', default_value = "150")
    # 2.把launch的参数手动传递给某个节点(就是手动赋值)
    """产生launch描述"""
    action_node_turtlesim_node = launch_ros.actions.Node(
        package = 'turtlesim',   # 功能包的名字
        executable = 'turtlesim_node',    # 可执行文件的名字
        parameters = [{'background_g': launch.substitutions.LaunchConfiguration('launch_arg_bg', default = "150")}],
        output = 'screen',    # 输出路径，screen表示输出到屏幕
        )
    action_node_patrol_client = launch_ros.actions.Node(
        package = 'demo_cpp_service',
        executable = 'patrol_client',
        output = 'log'  # log表示输出到日志文件
        )
    action_node_turtle_control = launch_ros.actions.Node(
        package = 'demo_cpp_service',
        executable = 'turtle_control',
        output = 'both' # both表示输出到屏幕的同时也输出到日志文件
        )
    return launch.LaunchDescription([
        # actions动作
        action_declare_arg_background_g,
        action_node_turtlesim_node,
        action_node_patrol_client,
        action_node_turtle_control,
        ])
